* ---------------------------- Table 13: Pricing terms on  nancing from new BDCs
use "$data_path/database_instrument_level_synthetic", clear 

forval i = 1/3 {
// treated vs control companies
reghdfe loan_rate_new i.ind_post##i.ind_treated_company c.company_instr_time_fe##i.ind_treated_company c.lag_assets_total_ln##i.ind_treated_company c.company_all_num##i.ind_treated_company c.lag_int_inc_net_avg_assets##i.ind_treated_company if spec`i' == 1, noabsorb vce(cluster company_all_num)
estadd local time_fe "No"
estadd local company_instr_time_fe "Yes"
estadd local controls "Yes"
estimates store reg_aa_`i'

// treated and control companies separately
forval j=0/1 {
reghdfe loan_rate_new i.ind_post company_instr_time_fe lag_assets_total_ln company_all_num lag_int_inc_net_avg_assets if ind_treated_company == `j' & spec`i' == 1, noabsorb vce(cluster company_all_num)
estadd local time_fe "No"
estadd local company_instr_time_fe "Yes"
estadd local controls "Yes"
estimates store reg_aa_`i'_`j'
}
}

local titles1 "&\multicolumn{3}{c}{All Debt} &\multicolumn{3}{c}{Subordinated} &\multicolumn{3}{c}{Senior} \\  \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-10}"
local titles2 "&\multicolumn{1}{c}{T vs C} &\multicolumn{1}{c}{T} &\multicolumn{1}{c}{C} &\multicolumn{1}{c}{T vs C} &\multicolumn{1}{c}{T} &\multicolumn{1}{c}{C} &\multicolumn{1}{c}{T vs C} &\multicolumn{1}{c}{T} &\multicolumn{1}{c}{C}\\  \midrule"

esttab reg_aa_1 reg_aa_1_1  reg_aa_1_0 ///
       reg_aa_2 reg_aa_2_1  reg_aa_2_0 ///
       reg_aa_3 reg_aa_3_1  reg_aa_3_0 ///
using "${tables_path}/table13.tex" /// 
,cells(b(star  fmt(2)) se(par  fmt(2))) stat(company_instr_time_fe controls r2 N, fmt(%~15s %~15s %9.2g %9.0g ) layout(\mc{@} \mc{@} @ \mc{@}) labels("$\reallywidehat{\text{Firm-Instrument-Year FE}}$" "BDC-Level Controls" "\$R^{2}\$" "\textit{N}")) /// 
style(tex) starlevels(^{*} 0.10  ^{**} 0.05 ^{***} 0.01)  nomtitles nonumbers collabels(none) ///
coeflabels(company_all_num "\$\overline{\text{Debt/Assets}}_{t-1}\$" 1.ind_treated_company#c.company_all_num "\$\overline{\text{Debt/Assets}}_{t-1}\$ $\times$ Treated Firm" lag_assets_total_ln "\$\overline{\text{ln(Assets}_{t-1}\text{)}}\$" 1.ind_treated_company#c.lag_assets_total_ln "\$\overline{\text{ln(Assets}_{t-1}\text{)}}\$ $\times$ Treated Firm" lag_int_inc_net_avg_assets "\$\overline{\text{Net Int. Inc./Assets}}_{t-1}\$"   1.ind_treated_company#c.lag_int_inc_net_avg_assets "\$\overline{\text{Net Int. Inc./Assets}}_{t-1}\$ $\times$ Treated Firm" company_instr_time_fe "Firm-Instrument-Type-Time FE" 1.ind_treated_company#c.company_instr_time_fe "Firm-Instrument-Type-Time FE $\times$ Treated Firm" _cons "Constant" 1.ind_post "Post" 1.ind_treated_company "Treated Firm" 1.ind_post#1.ind_treated_company "Post $\times$ Treated Firm" 1.ind_treated_company#1.tmp_sub "Treated Firm $\times$ Subordinated"  1.ind_post#1.ind_treated_company#1.tmp_sub "Post $\times$ Treated Firm $\times$ Subordinated" 1.tmp_sub "Subordinated" 1.ind_post#1.tmp_sub "Post $\times$ Subordinated" libor_03m "3 Month Libor" ) ///
order(1.ind_post 1.ind_treated_company 1.ind_post#1.ind_treated_company) keep(1.ind_post 1.ind_treated_company 1.ind_post#1.ind_treated_company) replace substitute(\_ _) noomit nobaselevels alignment(D{.}{.}{-1})  posthead("`titles1'" "`titles2'"  %) tex ///
nolines prefoot(\midrule) postfoot(\bottomrule \end{tabular} }) 
